package org.leaf.green.b2b

import org.leaf.green.admin.RecordType

class Purchase {//采购单

    RecordType recordType//记录类型
    String serialNumber//序号
    Date date//日期
    Dealer dealer//供应商
    Staff maker//制单人
    Staff director//负责人
    Date dateCreated
    Date lastUpdated    

    static hasMany = [details : PurchaseDetail]

    String toString(){
        return "${serialNumber}"
    }

    static constraints = {
        serialNumber(nullable:false, blank:false, unique:true, maxSize:11)
        date(nullable:false)
        dealer(nullable:true)
        maker(nullable:false)
        director(nullable:false)
    }

    static mapping = {
        table 'B2B_PURCHASE'
        details cascade:"all-delete-orphan", sort:"serialNumber", batchSize: 100
    }

}
